import axios from 'axios';
import nprogress from 'nprogress';
import 'nprogress/nprogress.css';
const instance = axios.create({
    baseURL: '/mock',
    timeout: 2000,
});
// 请求拦截器
instance.interceptors.request.use((config)=>{
    // 设置进度条开始
    nprogress.start();
    return config
})

// 响应拦截器
instance.interceptors.response.use((response)=>{
    // 设置进度条结束
    nprogress.done();
    return response.data
},(error)=>{
    return Promise.reject(error)
});

//对外暴露二次封装的axios
export default instance;